
package tools.packet;



import client.MapleCharacter;
import client.inventory.*;
import configs.ServerConfig;
import constants.ItemConstants;
import constants.ServerConstants;
import handling.channel.handler.EnchantHandler;
import handling.channel.handler.ItemScrollHandler;
import handling.opcode.SendPacketOpcode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.MapleItemInformationProvider;
import server.StructItemOption;
import server.maps.MapleMapItem;
import tools.DateUtil;
import tools.data.output.MaplePacketLittleEndianWriter;

import java.awt.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
































 public class InventoryPacket
         {
    /*  37 */   private static final Logger log = LogManager.getLogger(InventoryPacket.class);



    public static byte[] updateInventorySlotLimit(byte invType, byte newSlots) {
        /*  40 */
        log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
        /*  41 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /*  43 */
        mplew.writeShort(SendPacketOpcode.UPDATE_INVENTORY_SLOT.getValue());
        /*  44 */
        mplew.write(invType);
        /*  45 */
        mplew.write(newSlots);

        /*  47 */
        return mplew.getPacket();

    }



    public static byte[] updatePet(MaplePet pet, Item item, boolean summoned) {
        /*  51 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /*  53 */
        mplew.writeShort(SendPacketOpcode.MODIFY_INVENTORY_ITEM.getValue());
        /*  54 */
        mplew.write(0);
        /*  55 */
        mplew.write(2);
        /*  56 */
        mplew.write(0);
        /*  57 */
        mplew.write(3);
        /*  58 */
        mplew.write(5);
        /*  59 */
        mplew.writeShort(pet.getInventoryPosition());
        /*  60 */
        mplew.write(0);
        /*  61 */
        mplew.write(0);
        /*  62 */
        mplew.write(5);
        /*  63 */
        mplew.writeShort(pet.getInventoryPosition());
        /*  64 */
        mplew.write(3);
        /*  65 */
        mplew.writeInt(pet.getPetItemId());
        /*  66 */
        mplew.write(1);
        /*  67 */
        mplew.writeLong(pet.getUniqueId());
        /*  68 */
        PacketHelper.addPetItemInfo(mplew, item, pet, summoned);
        /*  69 */
        mplew.write(0);

        /*  71 */
        return mplew.getPacket();

    }



    public static byte[] petAddSkill(MapleCharacter player, MaplePet pet) {
        /*  75 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /*  77 */
        mplew.writeShort(SendPacketOpcode.PET_ADD_SKILL.getValue());
        /*  78 */
        mplew.writeInt(player.getId());
        /*  79 */
        mplew.write(1);
        /*  80 */
        mplew.writeInt(pet.getAddSkill());
        /*  81 */
        mplew.writeInt(0);
        /*  82 */
        mplew.writeInt(0);

        /*  84 */
        return mplew.getPacket();

    }



    public static byte[] modifyInventory() {
        /*  88 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /*  90 */
        mplew.writeShort(SendPacketOpcode.MODIFY_INVENTORY_ITEM.getValue());
        /*  91 */
        mplew.writeZeroBytes(3);

        /*  93 */
        return mplew.getPacket();

    }



    public static byte[] modifyInventory(boolean updateTick, List<ModifyInventory> mods) {
        /*  97 */
        return modifyInventory(updateTick, mods, null);

    }



    public static byte[] modifyInventory(boolean updateTick, List<ModifyInventory> mods, MapleCharacter chr) {
        /* 101 */
        return modifyInventory(updateTick, mods, chr, false);

    }















    public static byte[] modifyInventory(boolean updateTick, List<ModifyInventory> mods, MapleCharacter chr, boolean active) {
        /* 117 */
        log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
        /* 118 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 120 */
        mplew.writeShort(SendPacketOpcode.MODIFY_INVENTORY_ITEM.getValue());
        /* 121 */
        mplew.writeBool(updateTick);
        /* 122 */
        mplew.writeShort(mods.size());
        /* 123 */
        int addMovement = -1;
        /* 124 */
        for (ModifyInventory mod : mods) {
            /* 125 */
            mplew.write(mod.getMode());
            /* 126 */
            mplew.write(mod.getInventoryType());
            /* 127 */
            boolean oldpos = (mod.getMode() == 2 || mod.getMode() == 8 || (mod.getMode() == 5 && !mod.switchSrcDst()));
            /* 128 */
            mplew.writeShort(oldpos ? mod.getOldPosition() : mod.getPosition());
            /* 129 */
            switch (mod.getMode()) {

                case 0:
                    /* 131 */
                    PacketHelper.addItemInfo(mplew, mod.getItem(), chr, active);

                    break;

                case 1:
                    /* 134 */
                    mplew.writeShort(mod.getQuantity());

                    break;

                case 2:
                    /* 137 */
                    mplew.writeShort(mod.getPosition());
                    /* 138 */
                    if (mod.getPosition() < 0 || mod.getOldPosition() < 0) {
                        /* 139 */
                        addMovement = (mod.getOldPosition() < 0) ? 1 : 2;

                    }

                    break;

                case 3:
                    /* 143 */
                    if (mod.getPosition() < 0) {
                        /* 144 */
                        addMovement = 2;

                    }

                    break;

                case 4:
                    /* 148 */
                    mplew.writeLong(((Equip) mod.getItem()).getSealedExp());

                    break;

                case 5:
                    /* 151 */
                    mplew.writeShort(!mod.switchSrcDst() ? mod.getPosition() : mod.getOldPosition());
                    /* 152 */
                    if (mod.getIndicator() != -1) {
                        /* 153 */
                        mplew.writeShort(mod.getIndicator());

                    }

                    break;

                case 6:
                    /* 157 */
                    mplew.writeShort(mod.getQuantity());

                    break;




                case 8:
                    /* 163 */
                    mplew.writeShort(mod.getPosition());

                    break;

                case 9:
                    /* 166 */
                    PacketHelper.addItemInfo(mplew, mod.getItem());

                    break;

            }


            /* 171 */
            boolean bool = (mod.getItem() != null && ItemConstants.isArcaneForce(mod.getItem().getItemId())) ? true : false;

        }





        /* 178 */
        if (addMovement > -1) {
            /* 179 */
            mplew.write(addMovement);

        }

        /* 182 */
        return mplew.getPacket();

    }



    public static byte[] getInventoryFull() {
        /* 186 */
        return modifyInventory(true, Collections.emptyList());

    }



    public static byte[] getInventoryStatus() {
        /* 190 */
        return modifyInventory(false, Collections.emptyList());

    }



    public static byte[] getShowInventoryFull() {
        /* 194 */
        return getShowInventoryStatus(255, 0, (short) 0, 0);

    }



    public static byte[] showItemUnavailable() {
        /* 198 */
        return getShowInventoryStatus(254, 0, (short) 0, 0);

    }



    public static byte[] getShowInventoryStatus(int mode, int itemid, short number, int meso) {
        log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SHOW_STATUS_INFO.getValue());
        mplew.write(ServerConstants.MapleStatusInfo.获得道具.getType());
        mplew.write(mode);

        return mplew.getPacket();
    }

    public static byte[] showScrollTip(boolean success) {
        /* 250 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 252 */
        mplew.writeShort(SendPacketOpcode.SHOW_SCROLL_TIP.getValue());
        /* 253 */
        mplew.writeInt(success ? 1 : 0);

        /* 255 */
        return mplew.getPacket();

    }



    public static byte[] getScrollEffect(int chrId, int scroll, int toScroll) {
        /* 259 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 261 */
        mplew.writeShort(SendPacketOpcode.SHOW_SCROLL_EFFECT.getValue());
        /* 262 */
        mplew.writeInt(chrId);
        /* 263 */
        mplew.writeShort(1);
        /* 264 */
        mplew.writeInt(scroll);
        /* 265 */
        mplew.writeInt(toScroll);
        /* 266 */
        mplew.write(0);

        /* 268 */
        return mplew.getPacket();

    }



    public static byte[] getScrollEffect(int chrId, Equip.ScrollResult scrollSuccess, boolean legendarySpirit, boolean whiteScroll, int scroll, int toScroll) {
        /* 272 */
        log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
        /* 273 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 275 */
        mplew.writeShort(SendPacketOpcode.SHOW_SCROLL_EFFECT.getValue());
        /* 276 */
        mplew.writeInt(chrId);
        /* 277 */
        switch (scrollSuccess) {

            case 失败:
                /* 279 */
                mplew.write(0);

                break;

            case 成功:
                /* 282 */
                mplew.write(1);

                break;

            case 消失:
                /* 285 */
                mplew.write(2);

                break;

            default:
                /* 288 */
                throw new IllegalArgumentException("effect in illegal range");

        }
        /* 290 */
        mplew.write(legendarySpirit ? 0 : 0);
        /* 291 */
        mplew.writeInt(scroll);
        /* 292 */
        mplew.writeInt(toScroll);
        /* 293 */
        mplew.write(whiteScroll ? 1 : 0);

        /* 295 */
        return mplew.getPacket();

    }






    public static byte[] getPotentialEffect(int chrId, int itemid) {
        /* 302 */
        log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
        /* 303 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 305 */
        mplew.writeShort(SendPacketOpcode.SHOW_MAGNIFYING_EFFECT.getValue());
        /* 306 */
        mplew.writeInt(chrId);
        /* 307 */
        mplew.write(1);
        /* 308 */
        mplew.writeInt(itemid);

        /* 310 */
        return mplew.getPacket();

    }






    public static byte[] showMagnifyingEffect(int chrId, short pos, boolean isPotAdd) {
        /* 317 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 319 */
        mplew.writeShort(SendPacketOpcode.SHOW_MAGNIFYING_EFFECT.getValue());
        /* 320 */
        mplew.writeInt(chrId);
        /* 321 */
        mplew.writeShort(pos);
        /* 322 */
        mplew.write(isPotAdd ? 1 : 0);

        /* 324 */
        return mplew.getPacket();

    }



    public static byte[] showPotentialReset(boolean fireworks, int chrId, boolean success, int itemid, int eqitemid) {
        /* 328 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 330 */
        mplew.writeShort(fireworks ? SendPacketOpcode.SHOW_FIREWORKS_EFFECT.getValue() : SendPacketOpcode.SHOW_POTENTIAL_FINALPANEL.getValue());
        /* 331 */
        mplew.writeInt(chrId);
        /* 332 */
        mplew.write(success ? 1 : 0);
        /* 333 */
        mplew.writeInt(itemid);

        /* 335 */
        mplew.writeInt(2460002);
        /* 336 */
        mplew.writeInt(eqitemid);
        /* 337 */
        return mplew.getPacket();

    }



    public static byte[] showBlackCubeResults() {
        /* 341 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 343 */
        mplew.writeShort(SendPacketOpcode.MEMORIAL_CUBE_MODIFIED.getValue());
        /* 344 */
        mplew.write(0);

        /* 346 */
        return mplew.getPacket();

    }






    public static byte[] 潜能变化效果(int chrId, boolean success, int itemid) {
        /* 353 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 355 */
        mplew.writeShort(SendPacketOpcode.SHOW_ADDITIONAL_RESET.getValue());
        /* 356 */
        mplew.writeInt(chrId);
        /* 357 */
        mplew.write(success ? 1 : 0);
        /* 358 */
        mplew.writeInt(itemid);
        /* 359 */
        mplew.writeInt(0);
        /* 360 */
        mplew.writeInt(0);
        /* 361 */
        return mplew.getPacket();

    }






    public static byte[] 潜能扩展效果(int chrId, boolean success, int itemid, boolean 是否破坏) {
        /* 368 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 370 */
        mplew.writeShort(SendPacketOpcode.SHOW_ADDITIONAL_EFFECT.getValue());
        /* 371 */
        mplew.writeInt(chrId);
        /* 372 */
        mplew.write(success ? 1 : 0);
        /* 373 */
        mplew.writeInt(itemid);
        /* 374 */
        mplew.write(是否破坏 ? 1 : 0);

        /* 376 */
        return mplew.getPacket();

    }






    public static byte[] showNebuliteEffect(int chrId, boolean success, String msg) {
        /* 383 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 385 */
        mplew.writeShort(SendPacketOpcode.SHOW_NEBULITE_EFFECT.getValue());
        /* 386 */
        mplew.writeInt(chrId);
        /* 387 */
        mplew.write(success ? 1 : 0);
        /* 388 */
        mplew.writeMapleAsciiString(msg);

        /* 390 */
        return mplew.getPacket();

    }






    public static byte[] showSynthesizingMsg(int itemId, int giveItemId, boolean success) {
        /* 397 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 399 */
        mplew.writeShort(SendPacketOpcode.SYNTHESIZING_MSG.getValue());
        /* 400 */
        mplew.write(success ? 1 : 0);
        /* 401 */
        mplew.writeInt(itemId);
        /* 402 */
        mplew.writeInt(giveItemId);

        /* 404 */
        return mplew.getPacket();

    }



    public static byte[] dropItemFromMapObject(MapleMapItem drop, Point dropfrom, Point dropto, byte mod, boolean bl2) {
        /* 408 */
        return dropItemFromMapObject(drop, dropfrom, dropto, mod, bl2, 0);

    }



    public static byte[] dropItemFromMapObject(MapleMapItem drop, Point dropfrom, Point dropto, byte mod, boolean bl2, int skillid) {
        /* 412 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 414 */
        mplew.writeShort(SendPacketOpcode.DROP_ITEM_FROM_MAPOBJECT.getValue());
        /* 415 */
        mplew.write(0);
        /* 416 */
        mplew.write(mod);
        /* 417 */
        mplew.writeInt(drop.getObjectId());
        /* 418 */
        mplew.write((drop.getMeso() > 0) ? 1 : 0);
        /* 419 */
        mplew.writeZeroBytes(12);
        /* 420 */
        mplew.writeInt(drop.getItemId());
        /* 421 */
        mplew.writeInt(drop.getOwner());
        /* 422 */
        mplew.write(drop.getDropType());
        /* 423 */
        mplew.writePos(dropto);
        /* 424 */
        mplew.writeInt(skillid);
        /* 425 */
        mplew.writeInt(0);
        /* 426 */
        mplew.writeLong(0L);
        /* 427 */
        mplew.writeInt(0);
        /* 428 */
        mplew.writeLong(0L);
        /* 429 */
        mplew.writeInt(0);
        /* 430 */
        mplew.writeLong(0L);
        /* 431 */
        mplew.write(0);
        /* 432 */
        mplew.writeInt(0);
        /* 433 */
        mplew.write(0);
        /* 434 */
        if (mod != 2) {
            /* 435 */
            mplew.writePos(dropfrom);
            /* 436 */
            mplew.writeInt(drop.getDelay());

        }
        /* 438 */
        mplew.write(0);

        /* 440 */
        if (drop.getMeso() == 0) {
            /* 441 */
            PacketHelper.addExpirationTime(mplew, drop.getItem().getExpiration());

        }
        /* 443 */
        mplew.write(drop.isPlayerDrop() ? 0 : 1);
        /* 444 */
        mplew.write(0);
        /* 445 */
        mplew.writeShort(drop.getFallingVY());
        /* 446 */
        mplew.write(bl2 ? 2 : 0);
        /* 447 */
        mplew.writeInt(0);
        /* 448 */
        mplew.write(drop.getState() & 0xF);
        /* 449 */
        mplew.write(0);
        /* 450 */
        mplew.writeInt(0);
        /* 451 */
        return mplew.getPacket();

    }



    public static byte[] dropItemFromMapObject(MapleMapItem drop, Point dropfrom, Point dropto, byte mod) {
        /* 455 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 457 */
        mplew.writeShort(SendPacketOpcode.DROP_ITEM_FROM_MAPOBJECT.getValue());
        /* 458 */
        mplew.write(0);
        /* 459 */
        mplew.write(mod);
        /* 460 */
        mplew.writeInt(drop.getObjectId());
        /* 461 */
        mplew.write((drop.getMeso() > 0) ? 1 : 0);
        /* 462 */
        mplew.writeZeroBytes(12);
        /* 463 */
        mplew.writeInt(drop.getItemId());
        /* 464 */
        mplew.writeInt(drop.getOwner());
        /* 465 */
        mplew.write(drop.getDropType());
        /* 466 */
        mplew.writePos(dropto);
        /* 467 */
        mplew.writeInt(0);
        /* 468 */
        mplew.writeInt(0);
        /* 469 */
        mplew.writeLong(0L);
        /* 470 */
        mplew.writeInt(0);
        /* 471 */
        mplew.writeLong(0L);
        /* 472 */
        mplew.writeInt(0);
        /* 473 */
        mplew.writeLong(0L);
        /* 474 */
        mplew.write(0);
        /* 475 */
        mplew.writeInt(0);
        /* 476 */
        mplew.write(0);
        /* 477 */
        if (mod != 2) {
            /* 478 */
            mplew.writePos(dropfrom);
            /* 479 */
            mplew.writeInt(0);

        }
        /* 481 */
        mplew.write(0);

        /* 483 */
        if (drop.getMeso() == 0) {
            /* 484 */
            PacketHelper.addExpirationTime(mplew, drop.getItem().getExpiration());

        }
        /* 486 */
        mplew.writeInt(drop.isPlayerDrop() ? 0 : 1);
        /* 487 */
        mplew.writeZeroBytes(6);
        /* 488 */
        mplew.write(drop.getState());
        /* 489 */
        mplew.write(0);
        /* 490 */
        mplew.writeInt(0);
        /* 491 */
        return mplew.getPacket();

    }



    public static byte[] explodeDrop(int oid) {
        /* 495 */
        log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
        /* 496 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 498 */
        mplew.writeShort(SendPacketOpcode.REMOVE_ITEM_FROM_MAP.getValue());
        /* 499 */
        mplew.write(4);
        /* 500 */
        mplew.writeInt(oid);
        /* 501 */
        mplew.writeShort(655);

        /* 503 */
        return mplew.getPacket();

    }



    public static byte[] removeItemFromMap(int oid, int animation, int chrId) {
        /* 507 */
        return removeItemFromMap(oid, animation, chrId, 0);

    }



    public static byte[] removeItemFromMap(int oid, int animation, int chrId, int slot) {
        /* 511 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 513 */
        mplew.writeShort(SendPacketOpcode.REMOVE_ITEM_FROM_MAP.getValue());
        /* 514 */
        mplew.write(animation);
        /* 515 */
        mplew.writeInt(oid);
        /* 516 */
        if (animation >= 2) {
            /* 517 */
            mplew.writeInt(chrId);
            /* 518 */
            if (animation == 5) {
                /* 519 */
                mplew.writeInt(slot);

            }

        }

        /* 523 */
        return mplew.getPacket();

    }








    public static byte[] showPotionPotMsg(int reason) {
        /* 532 */
        return showPotionPotMsg(reason, 0);

    }



    public static byte[] showPotionPotMsg(int reason, int msg) {
        /* 536 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 538 */
        mplew.writeShort(SendPacketOpcode.POTION_POT_MSG.getValue());
        /* 539 */
        mplew.write(reason);
        /* 540 */
        if (reason == 0)
             {









            /* 551 */
            mplew.write(msg);

        }

        /* 554 */
        return mplew.getPacket();

    }






    public static byte[] updataPotionPot(MaplePotionPot potionPot) {
        /* 561 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 563 */
        mplew.writeShort(SendPacketOpcode.POTION_POT_UPDATE.getValue());
        /* 564 */
        PacketHelper.addPotionPotInfo(mplew, potionPot);

        /* 566 */
        return mplew.getPacket();

    }






    public static byte[] updataCoreAura(MapleCharacter chr) {
        /* 573 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 575 */
        mplew.writeShort(SendPacketOpcode.UPDATE_CORE_AURA.getValue());
        /* 576 */
        mplew.write(1);
        /* 577 */
        mplew.writeZeroBytes(6);
        /* 578 */
        mplew.write(4);
        /* 579 */
        mplew.writeZeroBytes(21);
        /* 580 */
        mplew.writeInt(8951284);
        /* 581 */
        mplew.writeLong(1L);
        /* 582 */
        PacketHelper.addCoreAura(mplew, chr);

        /* 584 */
        return mplew.getPacket();

    }






    public static byte[] showSkillSkin(Map<Integer, Integer> skillskinlist) {
        /* 591 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 593 */
        mplew.writeShort(SendPacketOpcode.SHOW_SKILL_SKIN.getValue());
        /* 594 */
        mplew.writeInt(2);
        /* 595 */
        mplew.writeInt(skillskinlist.size());

        /* 597 */
        for (Map.Entry<Integer, Integer> skillskin : skillskinlist.entrySet()) {
            /* 598 */
            mplew.writeInt(((Integer) skillskin.getKey()).intValue());
            /* 599 */
            mplew.writeInt(((Integer) skillskin.getValue()).intValue());

        }

        /* 602 */
        return mplew.getPacket();

    }






    public static byte[] showDamageSkin(int chrId, int skinId) {
        /* 609 */
        if (ServerConfig.DEBUG_MODE) {
            /* 610 */
            log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());

        }
        /* 612 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 614 */
        mplew.writeShort(SendPacketOpcode.SHOW_FOREIGN_DAMAGE_SKIN.getValue());
        /* 615 */
        mplew.writeInt(chrId);
        /* 616 */
        mplew.writeInt(skinId);
        /* 617 */
        mplew.writeMapleAsciiString("");
        /* 618 */
        mplew.writeMapleAsciiString("");
        /* 619 */
        return mplew.getPacket();

    }








    public static final byte[] showDamageSkin_Premium(int chrId, int skinId) {
        /* 628 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 630 */
        mplew.writeShort(SendPacketOpcode.SHOW_DAMAGE_SKIN_PREMIUM.getValue());
        /* 631 */
        mplew.writeInt(chrId);
        /* 632 */
        mplew.writeInt(skinId);
        /* 633 */
        mplew.writeMapleAsciiString("");
        /* 634 */
        mplew.writeMapleAsciiString("");
        /* 635 */
        return mplew.getPacket();

    }



    public static byte[] enchantingOperation(int n2, int n3, Item toScroll, Item scrolled, List<EnchantScrollEntry> scrollEntries) {
        /* 639 */
        return enchantingOperation(n2, n3, toScroll, scrolled, scrollEntries, "");
    }

    public static byte[] enchantingOperation(int mode, int success, Item toScroll, Item scrolled, List<EnchantScrollEntry> scrollEntries, String string) {
        Equip equip;

        byte enhance;

        boolean isSuperiorEquip, bl3;

        int n5, n6, n7;
        /* 643 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 645 */
        mplew.writeShort(SendPacketOpcode.ENCHANTING_OPERATION.getValue());
        /* 646 */
        mplew.write(mode);
        /* 647 */
        switch (mode) {

            case 50:
                /* 649 */
                mplew.write(0);
                /* 650 */
                mplew.write(scrollEntries.size());
                /* 651 */
                for (EnchantScrollEntry scrollEntry : scrollEntries) {
                    /* 652 */
                    mplew.writeInt(scrollEntry.getViewType());
                    /* 653 */
                    mplew.writeMapleAsciiString(scrollEntry.getName());
                    /* 654 */
                    mplew.writeInt((scrollEntry.getViewType() == 4) ? 1 : ((scrollEntry.getViewType() == 5) ? 2 : 0));
                    /* 655 */
                    mplew.writeInt((scrollEntry.getViewType() >= 4) ? 1 : 0);
                    /* 656 */
                    mplew.writeInt(scrollEntry.getMask());
                    /* 657 */
                    if (scrollEntry.getMask() > 0) {
                        /* 658 */
                        for (int n4 : scrollEntry.getValues()) {
                            /* 659 */
                            mplew.writeInt(n4);

                        }

                    }
                    /* 662 */
                    mplew.writeInt(scrollEntry.getNeed() * ItemScrollHandler.getNeedRate(((Equip) scrolled).getReqLevel()));
                    /* 663 */
                    mplew.writeInt(scrollEntry.getNeed() * ItemScrollHandler.getNeedRate(((Equip) scrolled).getReqLevel()));
                    /* 664 */
                    mplew.write((scrollEntry.getSucess() == 100) ? 1 : 0);

                }

                break;


            case 51:
                /* 669 */
                mplew.write(0);

                break;


























            case 52:
                /* 697 */
                equip = (Equip) toScroll;
                /* 698 */
                enhance = equip.getEnhance();
                /* 699 */
                isSuperiorEquip = MapleItemInformationProvider.getInstance().isSuperiorEquip(equip.getItemId());
                /* 700 */
                bl3 = equip.getStartCurse();
                /* 701 */
                n5 = equip.getNeedStar() * 10;
                /* 702 */
                n6 = bl3 ? ((1000 - n5) * (isSuperiorEquip ? (enhance - 4) : (enhance - 14)) / 18) : 0;
                /* 703 */
                n7 = 2 * (enhance * enhance + 2);
                /* 704 */
                mplew.writeBool(equip.getStartDown());
                /* 705 */
                mplew.writeLong(n7);
                /* 706 */
                mplew.writeShort(0);
                /* 707 */
                mplew.writeInt(0);
                /* 708 */
                mplew.writeInt(0);
                /* 709 */
                mplew.writeInt(0);
                /* 710 */
                mplew.writeInt(0);
                /* 711 */
                mplew.writeInt(n5);
                /* 712 */
                mplew.writeInt((enhance < 15) ? -n6 : n6);
                /* 713 */
                mplew.writeInt(0);
                /* 714 */
                mplew.writeInt(0);
                /* 715 */
                mplew.writeBool(equip.getBonusTime());
                /* 716 */
                writeMaskEnchantScroll(mplew, toScroll);

                break;


            case 53:
                /* 720 */
                mplew.write(0);
                /* 721 */
                mplew.writeInt(DateUtil.getTime());

                break;


            case 100:
                /* 725 */
                mplew.write(0);
                /* 726 */
                mplew.writeInt(success);
                /* 727 */
                mplew.writeMapleAsciiString(string);
                /* 728 */
                PacketHelper.addItemInfo(mplew, toScroll);
                /* 729 */
                if (success == 2) {
                    /* 730 */
                    mplew.writeShort(0);

                    break;

                }
                /* 733 */
                PacketHelper.addItemInfo(mplew, scrolled);

                break;


            case 101:
                /* 737 */
                mplew.write(success);
                /* 738 */
                mplew.writeInt(0);
                /* 739 */
                PacketHelper.addItemInfo(mplew, toScroll);
                /* 740 */
                PacketHelper.addItemInfo(mplew, scrolled);

                break;


            case 102:
                /* 744 */
                mplew.writeInt(success);

                break;


            case 103:
                /* 748 */
                PacketHelper.addItemInfo(mplew, toScroll);
                /* 749 */
                PacketHelper.addItemInfo(mplew, scrolled);

                break;


            case 104:
                /* 753 */
                mplew.write(0);

                break;


            case 105:
                /* 757 */
                PacketHelper.addItemInfo(mplew, toScroll);
                /* 758 */
                PacketHelper.addItemInfo(mplew, scrolled);

                break;

        }
        /* 761 */
        return mplew.getPacket();
    }




    public static void writeMaskEnchantScroll(MaplePacketLittleEndianWriter mplew, Item item) {
        /* 765 */
        Map<EnchantScrollFlag, Integer> scrollList = EnchantHandler.Companion.getEnchantScrollList(item, false);
        /* 766 */
        int mask = 0;
        /* 767 */
        for (EnchantScrollFlag flag : scrollList.keySet()) {
            /* 768 */
            if (scrollList.containsKey(flag) && ((Integer) scrollList.get(flag)).intValue() > 0) {
                /* 769 */
                mask |= flag.getValue();

            }

        }
        /* 772 */
        mplew.writeInt(mask);
        /* 773 */
        if (mask != 0) {
            /* 774 */
            for (EnchantScrollFlag flag : EnchantScrollFlag.values()) {
                /* 775 */
                if (scrollList.containsKey(flag) && ((Integer) scrollList.get(flag)).intValue() > 0) {
                    /* 776 */
                    mplew.writeInt(((Integer) scrollList.get(flag)).intValue());

                }

            }

        }

    }



    public static byte[] getZeroWeaponInfo(int weaponlevel, int level, int weapon1, int weapon2) {
        /* 783 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 785 */
        mplew.writeShort(SendPacketOpcode.SHOW_ZERO_WEAPON_INFO.getValue());
        /* 786 */
        mplew.writeShort(0);
        /* 787 */
        mplew.writeInt(weaponlevel);
        /* 788 */
        mplew.writeInt(level);
        /* 789 */
        mplew.writeInt(weapon1);
        /* 790 */
        mplew.writeInt(weapon2);
        /* 791 */
        mplew.write(0);

        /* 793 */
        return mplew.getPacket();

    }



    public static byte[] getZeroWeaponChangePotential(int meso, int wp) {
        /* 797 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 799 */
        mplew.writeShort(SendPacketOpcode.SHOW_CHANGE_POTENTIAL_MESO.getValue());
        /* 800 */
        mplew.writeInt(1);
        /* 801 */
        mplew.writeInt(meso);
        /* 802 */
        mplew.writeInt(wp);
        /* 803 */
        mplew.writeShort(1);

        /* 805 */
        return mplew.getPacket();

    }



    public static byte[] showZeroWeaponChangePotentialResult(boolean succ) {
        /* 809 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 811 */
        mplew.writeShort(SendPacketOpcode.SHOW_CHANGE_POTENTIAL_RESULT.getValue());
        /* 812 */
        mplew.write(1);
        /* 813 */
        mplew.writeBool(succ);

        /* 815 */
        return mplew.getPacket();

    }



    public static byte[] showHyunPotentialResult(boolean result, int size, List<StructItemOption> potids) {
        /* 819 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 821 */
        mplew.writeShort(SendPacketOpcode.SHOW_POTENTIAL_RESULT.getValue());
        /* 822 */
        mplew.writeShort(result ? 1 : 0);
        /* 823 */
        mplew.writeInt(0);
        /* 824 */
        if (!result) {
            /* 825 */
            mplew.writeInt(size);
            /* 826 */
            mplew.writeInt(potids.size());
            /* 827 */
            potids.forEach(integer -> mplew.writeInt(integer.opID));

        }

        /* 830 */
        return mplew.getPacket();

    }



    public static byte[] showCubeResetResult(int equipPosition, Item toScroll, int cubeid, int Surplus, int cubePosition) {
        /* 834 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 836 */
        mplew.writeShort((cubeid == 5062090) ? SendPacketOpcode.MEMORIAL_CUBE_RESULT.getValue() : ((cubeid == 5062503) ? SendPacketOpcode.WHITEADDITIONAL_CUBE_RESULT.getValue() : SendPacketOpcode.BLACKY_CUBE_EFFECT.getValue()));
        /* 837 */
        mplew.writeLong((toScroll.getInventoryId() <= 0L) ? toScroll.getEquipOnlyId() : toScroll.getInventoryId());
        /* 838 */
        mplew.write(1);
        /* 839 */
        PacketHelper.addItemInfo(mplew, toScroll);
        /* 840 */
        mplew.writeInt(cubeid);
        /* 841 */
        mplew.writeInt(equipPosition);
        /* 842 */
        mplew.writeInt(Surplus);
        /* 843 */
        mplew.writeInt(cubePosition);

        /* 845 */
        return mplew.getPacket();

    }




    public static byte[] showCubeResult(int chrid, int cubeid, int position, int Surplus, Item equip) {
        /* 850 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        /* 851 */
        short opcode = 0;
        /* 852 */
        boolean isReuse = true;
        /* 853 */
        switch (cubeid) {

            case 5062022:
                /* 855 */
                isReuse = false;
                /* 856 */
                opcode = SendPacketOpcode.SHOW_SHININGMIRROR_CUBE_RESULT.getValue();

                break;


            case 5062009:
                /* 860 */
                opcode = SendPacketOpcode.SHOW_REDCUBE_RESULT.getValue();

                break;


            case 5062500:

            case 5062501:

            case 5062502:
                /* 866 */
                opcode = SendPacketOpcode.SHOW_ADDITIONALCUBE_RESULT.getValue();

                break;


            default:
                /* 870 */
                opcode = SendPacketOpcode.SHOW_INGAMECUBE_RESULT.getValue();

                break;

        }

        /* 874 */
        mplew.writeShort(opcode);
        /* 875 */
        mplew.writeInt(chrid);
        /* 876 */
        mplew.write(0);
        /* 877 */
        mplew.writeInt(cubeid);
        /* 878 */
        mplew.writeInt(position);
        /* 879 */
        if (isReuse) {
            /* 880 */
            mplew.writeInt(Surplus);

        }
        /* 882 */
        PacketHelper.addItemInfo(mplew, equip);

        /* 884 */
        return mplew.getPacket();

    }



    public static byte[] showTapJoyInfo(int slot, int itemid) {
        /* 888 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        /* 889 */
        int i1 = itemid % 10 - 1;
        /* 890 */
        mplew.writeShort(SendPacketOpcode.TAP_JOY_INFO.getValue());
        /* 891 */
        mplew.write(5);
        /* 892 */
        mplew.writeInt(i1);
        /* 893 */
        mplew.writeInt(slot);
        /* 894 */
        mplew.writeInt(itemid);
        /* 895 */
        mplew.write(0);
        /* 896 */
        mplew.writeInt(350 * (i1 / 2 + 2));
        /* 897 */
        int size = ItemConstants.TapJoyReward.getStages().size() / 2;
        /* 898 */
        mplew.writeInt(5840000 + i1);
        /* 899 */
        mplew.writeInt(size);
        /* 900 */
        for (int i = 0; i < size; i++) {
            /* 901 */
            mplew.writeInt(i);
            /* 902 */
            mplew.writeInt(((Integer) ItemConstants.TapJoyReward.getItemIdAndSN(i * 2).getLeft()).intValue());
            /* 903 */
            mplew.writeInt(((Integer) ItemConstants.TapJoyReward.getItemIdAndSN(i * 2).getRight()).intValue());
            /* 904 */
            mplew.writeInt(((Integer) ItemConstants.TapJoyReward.getItemIdAndSN(i * 2 + 1).getLeft()).intValue());
            /* 905 */
            mplew.writeInt(((Integer) ItemConstants.TapJoyReward.getItemIdAndSN(i * 2 + 1).getLeft()).intValue());
            /* 906 */
            mplew.writeInt(100);
            /* 907 */
            mplew.writeInt(350 * (i / 2 + 2));
            /* 908 */
            mplew.writeInt(4009441 + i);
            /* 909 */
            mplew.writeInt(5840000 + i);

        }

        /* 912 */
        return mplew.getPacket();

    }



    public static byte[] showTapJoy(int reward) {
        /* 916 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 918 */
        mplew.writeShort(SendPacketOpcode.TAP_JOY.getValue());
        /* 919 */
        mplew.writeInt(reward);

        /* 921 */
        return mplew.getPacket();

    }



    public static byte[] showTapJoyDone(int mode, int itemid, int intValue3, int gainslot, int intValue) {
        /* 925 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 927 */
        mplew.writeShort(SendPacketOpcode.TAP_JOY_DONE.getValue());
        /* 928 */
        mplew.write(mode);
        /* 929 */
        mplew.writeInt(itemid);
        /* 930 */
        mplew.writeInt(intValue3);
        /* 931 */
        mplew.writeInt(4);
        /* 932 */
        mplew.writeInt(gainslot);
        /* 933 */
        mplew.writeInt(0);
        /* 934 */
        mplew.writeInt(intValue);

        /* 936 */
        return mplew.getPacket();

    }



    public static byte[] showTapJoyNextStage(MapleCharacter player, int n, int n2, int n3, int n4) {
        /* 940 */
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        /* 942 */
        mplew.writeShort(SendPacketOpcode.TAP_JOY_NEXT_STAGE.getValue());
        /* 943 */
        mplew.write(n);
        /* 944 */
        mplew.writeInt(n3);
        /* 945 */
        mplew.writeInt(5);
        /* 946 */
        mplew.writeInt(n2);
        /* 947 */
        mplew.writeInt(n3);
        /* 948 */
        mplew.write(n4);
        /* 949 */
        mplew.writeInt(player.getCSPoints(n4));

        /* 951 */
        return mplew.getPacket();

    }

}


/* Location:              C:\PGX\Server.jar!\tools\packet\InventoryPacket.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */